import pytest
#function 范围最小 class 类的范围 module 模块级别 session 最大范围
@pytest.fixture(scope='function')

def gettoken():
    print("获取token的代码")
    token=123456
    yield token
    print('根据scope范围结束后的操作')

from appium import webdriver
from time import sleep
import os
@pytest.fixture(scope='session')

def getdriver():
    os.system("adb root")
    cap={
        "platformName": "Android",
        "appium:deviceName": "emulator-5554",
        "appPackage": "com.kongfz.app",
        "appActivity": "com.kongfz.app.home.mvvm.homepage.HomeActivity",
        "noReset":True
    }

    deiver=webdriver.Remote("http://127.0.0.1:4723/wd/hub",cap)

    deiver.implicitly_wait(60)

    sleep(30)

    yield deiver

    deiver.quit()






